package org.example.rmsmsapi.dao;

import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.example.rmsmsapi.config.DS;
import org.example.rmsmsapi.model.MRCBean;
import org.example.rmsmsapi.model.testUser;
import org.example.rmsmsapi.model.ybbxInfo;

import java.util.List;

@Mapper

public interface testMapper {
    @Select("select SSUSR_Initials,SSUSR_Name from ss_user")
    List<testUser>getUser();
    @Select("SELECT  INPAY_bcbxf0 zje,INPAY_djlsh0 ybjsid ,INPAY_grzfe0 grzfhjje, INPAY_bcbxf0-INPAY_jjzfe0-isnull(InPay_zsTR12,0) nrecbzje,\n" +
            "        INPAY_jjzfe0 jjzfze,INPAY_xming0 hzxm,INPAY_zyksmc zyksmc,\n" +
            "                  INPAY_zylsh0 jzid,isnull(InPay_zsTR12,0) zfje,INPAY_Zstr13 ylxxzfje,INPAY_Zstr14 cxjzffy, INPAY_Zstr26 tcjjzffwnfy,\n" +
            "                 INPAY_sfrq00 sfrq, INPAY_sfrxm0 ybjbrxm,INPAY_Zstr09 qfx,INPAY_brnl00 brnl,\n" +
            "                  INPAY_xbie00 xb, b.PAADM_AdmDate ryrq,b.PAADM_DischgDate cyrq,b.PAADM_DischgDate-b.PAADM_AdmDate zyts,\n" +
            "                   c.PAPMI_DVAnumber sfzh,c.PapmI_No djh,c.PAPMI_Name brname,d.MrNo  zyh,b.PAADM_RowID  jzh,  isnull(INPAY_InsuPay1,'0')jbylbx,isnull(INPAY_InsuPay4,'0')yljz,isnull(INPAY_grzfe0,0)grxjzfje,isnull(INPAY_zhzfe0,0)grzhzfje,\n" +
            "        isnull(INPAY_InsuPay6,'0')jmdbbx, isnull(INPAY_InsuPay2,0)zgdebc,isnull(INPAY_Zstr23,0)grzhye,f.INADM_Center cbdbh\n" +
            "FROM pa_patmas c left join  pa_adm b on\n" +
            "                   C.PAPMI_RowId=b.PAADM_PAPMI_DR left join\n" +
            "                  INSU_Divide a  on b.pAADM_rOWID=a.INPAY_AdmDr left join MA_IPMR_SS.MedicareNo d on a.INPAY_AdmDr=EpisodeID\n" +
            "               left join INSU_AdmInfo f on b.PAADM_RowID=f.INADM_AdmDr\n" +
            "            where c.PAPMI_DVAnumber=#{sfzh} and b.PAADM_Type='I'  and a.INPAY_Flag='I'")
    List<ybbxInfo> GetybinfobyId(@Param("sfzh")String sfzh);
    @Select("SELECT top 1 MRDIA_ICDCode_DR->MRCID_Desc , MRDIA_MRADM_ParRef->MRADM_ADM_DR ,MRDIA_MainDiagFlag " +
            "FROM MR_Diagnos LEFT JOIN MR_DiagType ON MR_Diagnos.MRDIA_RowId=MR_DiagType.TYP_ParRef  WHERE" +
            " MRDIA_MRADM_ParRef->MRADM_ADM_DR=#{jzh}  and TYP_MRCDiagTyp=1 and MRDIA_MainDiagFlag=#{lx}")
    /**获取主要诊断**/
    MRCBean GetMrcFirst(@Param("jzh") String jzh,@Param("lx")String lx);

    @Select("SELECT  MRDIA_ICDCode_DR->MRCID_Desc , MRDIA_MRADM_ParRef->MRADM_ADM_DR ,MRDIA_MainDiagFlag " +
            "FROM MR_Diagnos LEFT JOIN MR_DiagType ON MR_Diagnos.MRDIA_RowId=MR_DiagType.TYP_ParRef  WHERE" +
            " MRDIA_MRADM_ParRef->MRADM_ADM_DR=#{jzh}  and TYP_MRCDiagTyp=1 and MRDIA_MainDiagFlag='N'")
    /**获取出院其他真的诊断**/
    List<MRCBean> GetMrcEnd(@Param("jzh") String jzh);
    @Select("SELECT b.INDID_DicDesc  FROM INSU_AdmInfo a ,INSU_DicData b WHERE a.INADM_AdmDr=#{jzh} AND a.INADM_AdmType=b.INDID_DicCode AND b.INDID_DicType='med_type00A' ")
    /**获取医疗类别**/
    String GetYllb(@Param("jzh")String jzh);
    @Select("SELECT b.INDID_DicDesc  FROM INSU_AdmInfo a ,INSU_DicData b WHERE a.INADM_AdmDr=#{jzh} AND a.INADM_CardStatus=b.INDID_DicCode AND b.INDID_DicType='insutype00A'")
    /**获取险种类别*/
    String Getxzlb(@Param("jzh")String jzh);
}
